﻿<!DOCTYPE html>
<!--承包商入场人员名单编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
            size="mini">
            <!--<el-row>
            <el-col :span="10">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input type="text" v-model="Form.ContractorName" autocomplete="off" size="mini" :disabled="true">
                            <template slot="prepend">
                                {{ContractorAdmissionList.ContractorName+mark.m}}
                            </template>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
            <el-col :span="2">
                <el-button type="primary" @click="ContractorInput('tj')">{{col.Choose}}</el-button>
            </el-col>
            <el-col :span="10">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input type="text" v-model="Form.AdmissionName" autocomplete="off" size="mini" :disabled="true">
                            <template slot="prepend">
                                {{ContractorAdmissionList.AdmissionName+mark.m}}
                            </template>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
            <el-col :span="2">
                <el-button type="primary" @click="UserInput('tj')">{{col.Choose}}</el-button>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="11">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input type="text" v-model="Form.Region" autocomplete="off" size="mini" >
                            <template slot="prepend">
                                {{ContractorAdmissionList.Region+mark.m}}
                            </template>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
            <el-col :span="11" :offset="2">
                <el-form-item :label="ContractorAdmissionList.AdmissionTime+mark.m" prop="AdmissionTime">
                    <el-date-picker v-model="Form.AdmissionTime"
                                    type="datetime"
                                    placeholder="选择日期时间">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="11">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input type="text" v-model="Form.AdmissionConfirmer" autocomplete="off" size="mini" >
                            <template slot="prepend">
                                {{ContractorAdmissionList.AdmissionConfirmer+mark.m}}
                            </template>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>
        </el-row>-->

            <el-row>
                <el-col class="head-tool">
                    <el-button type="primary" @click="UserInput('tj')">添加人员</el-button>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="13">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.ContractorName" autocomplete="off" size="mini"
                                :disabled="true">
                                <template slot="prepend">
                                    {{ContractorAdmissionList.ContractorName+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4" offset="1">
                    <el-button type="primary" @click="ContractorInput('tj')">{{col.Choose}}</el-button>
                </el-col>
                <el-col :span="13">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.Region" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{ContractorAdmissionList.Region+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <!--<el-col :span="11" :offset="2">
                <div class="elst-select-mini">
                    <el-form-item>
                        <el-input type="text" v-model="Form.phone" autocomplete="off" size="mini">
                            <template slot="prepend">
                                {{ContractorAdmissionTool.phone+mark.m}}
                            </template>
                        </el-input>
                    </el-form-item>
                </div>
            </el-col>-->
            </el-row>

            <el-row>
                <el-col span="24">
                    <el-table stripe :data="Form.PeopleList" border>
                        <el-table-column prop="PeopleName" :label="ContractorAdmissionList.AdmissionName">
                        </el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button @click.native.prevent="deleteRow(scope.$index, Form.PeopleList)" type="text"
                                    size="small">
                                    移除
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-col>
            </el-row>
            <br />
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="onBack">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        <el-dialog :title="title" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%" height="80%"
            top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                id: '',
                title: '',
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    AdmissionName: '',
                    Region: '',
                    AdmissionTime: '',
                    ContractorName: '',
                    AdmissionConfirmer: '',
                    PeopleList: [],
                },
                ListItem: ListItem,
                //表单验证
                rules: {
                    AdmissionName: [
                        verification.NotNull,
                    ],
                    ContractorName: [
                        verification.NotNull,
                        { pattern: verification.StringLengthAtoB.t.format(5, 50), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }
                    ],
                    Region: [
                        verification.NotNull
                    ],
                    AdmissionTime: [
                        verification.NotNull
                    ]
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },

                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/ContractorAdmission/Save', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                getData: function () {
                    getData(this, '/api/ContractorAdmission/get?id=' + this.id);
                },
                UserInput: function (val, id) {
                    this.title = "承包商人员列表";
                    // DialogShow(this, val, "ContractorPersonnelAdmissionInputPeople.html", id);
                    DialogShow(this, val, "ContractorPersonnelAdmissionAdd.html", id);

                },


                ContractorInput: function (val, id) {
                    this.title = "承包商列表";
                    DialogShow(this, val, "ContractorDirectoryList.html", id);
                },
                onBack: function () {
                    parent.app.ListItem.dialogVisible = false;
                }
            },
            mounted: function () {

                this.id = getUrlParam("id");
                this.getData();
            }
        });
    </script>
</body>

</html>